﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using _22yards.IndependentModules;
namespace _22yards.Core
{
    public class MatchPlayEngine : IBattingEngine, IBowlingEngine
    {
        //private TournamentStructure.Match currentMatch;

        private short innings;
        private short OversPerDay;
        private short OversPerInnings;

        private short InningsCompleted;
        private short OversInCurrentInningsCompleted;
        private short OversInCurrentDayCompleted;

        private short TotalOversBowledbyTeam1;
        private short TotalExtrasBowledbyTeam1;
        private short TotalOversBowledbyTeam2;
        private short TotalExtrasBowledbyTeam2;

        private short ballsBowledInCurrentOver;
        private short ExtrasBowledInCurrentOver;

        private Match match;

        Team Team1;
        Team Team2;

        public void InitMatch(Team _team1, Team _team2, short typeofmatch /**/)
        {
            //match = _match;
            Team1 = _team1;
            Team2 = _team2;
            match = new Match(Team1, Team2, typeofmatch);

            //Load rules
            //innings = whatever rule says
            //OversPerDay = depends on rule;
            //OversPerInnings = depends on rule;
            InningsCompleted = 0;
            OversInCurrentInningsCompleted = 0;
            OversInCurrentDayCompleted = 0;

            TotalOversBowledbyTeam1 = 0;
            TotalExtrasBowledbyTeam1 = 0;
            TotalOversBowledbyTeam2 = 0;
            TotalExtrasBowledbyTeam2 = 0;

            ballsBowledInCurrentOver = 0;
            ExtrasBowledInCurrentOver = 0;
        }

        public void SaveMatch()
        {
            throw new NotImplementedException();
        }

        public void LoadMatch()
        {
            throw new NotImplementedException();
        }

        public void TossCoin(int call /* 0 for head, 1 for call*/)
        {
            Toss.Call(ref Team1, ref Team2, call);
        }
    }
}

